/*
 * Ext JS Library 2.0 RC 1
 * Copyright(c) 2006-2007, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */
/*
 * Ext JS Library 2.0 RC 1
 * Copyright(c) 2006-2007, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */

Ext.onReady(function(){
    // shorthand

    var Tree = Ext.tree;
   
    var tree = new Tree.TreePanel({
        el:'tree-div',
        autoScroll:true,
        animate:true,
        enableDD:true,
        containerScroll: true, 
        loader: new Tree.TreeLoader({
            dataUrl:'en/Special:selectTree',
            baseParams:{categoryId:0}
        })
         
    });
    tree.on("beforeload", function(treeLoader, node) {
	 	tree.loader.baseParams.categoryId = treeLoader.id;
    	}, this);
     tree.on("dblclick", function(node) { 
     	 if(node.isLeaf()){
		     opener.document.getElementById('categoryId').value=node.id;
		     opener.document.getElementById('categoryName').value=node.text;
		     window.close();
	     }
    	}, this);
    // set the root node
    var root = new Tree.AsyncTreeNode({
        text: 'WIKI',
        draggable:false,
        id:'0'
    });
    tree.setRootNode(root);

    // render the tree
    tree.render();
    tree.expandAll();
    root.expand();
    tree.on('click', function(node){ 
        if(!node.isLeaf())
        node.unselect();
      });
});
function getSelect(){


}
